<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="__PUBLIC__/admin/lib/html5.js"></script>
    <script type="text/javascript" src="__PUBLIC__/admin/lib/respond.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/admin/lib/PIE_IE678.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/lib/Hui-iconfont/1.0.7/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/lib/icheck/icheck.css" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/static/h-ui.admin/css/style.css" />
    <link rel="stylesheet" href="__PUBLIC__/admin/index.css">
    <!--[if IE 6]>
    <script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>角色管理</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 用户管理 <span class="c-gray en">&gt;</span>用户列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <form method="get" action="">
    <div class="text-c">注册时间：
        <input type="text" name="startTime" value="<?php echo isset($display['startTime']) ? $display['startTime'] : ''?>" onfocus="WdatePicker()" id="datemin" class="input-text Wdate" style="width:120px;">
        至
        <input type="text" name="endTime" value="<?php echo isset($display['endTime']) ? $display['endTime'] : ''?>"   onfocus="WdatePicker()" id="datemax" class="input-text Wdate" style="width:120px;">
        <input type="text" name="searchName" value="<?php echo isset($display['searchName']) ? $display['searchName'] : ''?>" class="input-text" style="width:250px" placeholder="输入用户名、昵称" id="" >
        <select class="select-box" style="width: 90px;padding: 5px 5px;" size="1" name="type">
            <option value="" selected >用户类型</option>
            <option value="3" <?php if(isset($display['type']) && $display['type'] == 3) echo 'selected';?>>会员</option>
            <option value="2" <?php if(isset($display['type']) && $display['type'] == 2) echo 'selected';?>>助理</option>
        </select>
        <select class="select-box" style="width: 80px;padding: 5px 5px;" size="1" name="status">
            <option value="" selected>状态</option>
            <option value="1" <?php if(isset($display['status']) && $display['status'] == 1) echo 'selected';?>>已启用</option>
            <option value="2" <?php if(isset($display['status']) && $display['status'] == 2) echo 'selected';?>>已禁用</option>
        </select>
        <select class="select-box" style="width: 90px;padding: 5px 5px;" size="1" name="account_binding">
            <option value="0" selected>账号绑定</option>
            <option value="1" <?php if(isset($display['account_binding']) && $display['account_binding'] ==1 ) echo 'selected';?> >手机+微信</option>
            <option value="2" <?php if(isset($display['account_binding']) && $display['account_binding'] ==2 ) echo 'selected';?> >仅微信</option>
            <option value="3" <?php if(isset($display['account_binding']) && $display['account_binding'] ==3 ) echo 'selected';?> >仅手机</option>
        </select>
        <select class="select-box" style="width: 90px;padding: 5px 5px;" size="1" name="is_remind">
            <option value="" selected>短信提醒</option>
            <option value="1" <?php if(isset($display['is_remind']) && $display['is_remind'] ==1 ) echo 'selected';?> >是</option>
            <option value="2" <?php if(isset($display['is_remind']) && $display['is_remind'] ==2 ) echo 'selected';?> >否</option>
        </select>
        <button type="submit" class="btn btn-success radius" style="margin-right: 300px;"><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
    </div>
    <div class="cl pd-5 bg-1 bk-gray"> <span class="l">
		<a class="btn btn-primary radius" href="javascript:;" onclick="admin_add('添加用户','<?php echo Url('User/userAdd')?>','800')"><i class="Hui-iconfont">&#xe600;</i> 添加用户</a> </span>
        &nbsp;&nbsp;

        <a href="<?php echo url('User/export')?>?exportwhere=<?php echo urlencode($exportwhere);?>"  class="btn btn-danger radius"><i class="Hui-iconfont">&#xe644;</i> 导出Excel</a>
    </div>
    <div class="mt-20">
        <table class="table table-border table-bordered table-bg table-hover table-sort">
            <thead>
            <tr>
                <th scope="col" colspan="15">用户列表</th>
            </tr>
            <tr class="text-c">
                <th width="40">ID</th>
                <th width="200">用户名</th>
                <th width="150">账号绑定</th>
                <th width="100">昵称</th>
                <th width="100">姓名</th>
                <th width="100">类型</th>
                <th width="200">产品</th>
                <th width="150">当前产品有效期</th>
                <th width="100">积分</th>
                <th width="100">注册来源</th>
                <th width="100">短信提醒</th>
                <th width="200">最后登陆时间</th>
                <th width="200">注册时间</th>
                <th width="100">状态</th>
                <th width="100">操作</th>
            </tr>
            </thead>
            <tbody>
            <?php foreach($result['list'] as $v){?>
            <tr class="text-c">
            <td><?php echo $v['uid']?></td>
            <td><?php echo $v['username']?></td>
            <td><?php if(!empty($v['openid']) && empty($v['username'])){
                echo '仅微信';            }else if(!empty($v['username']) && empty($v['openid'])){
                echo '仅手机';            }else if(!empty($v['openid']) && !empty($v['username'])){
                echo '手机+微信';}?></td>
            <td><?php echo $v['nickname']?></td>
            <td><?php echo $v['real_name']?></td>
            <td><?php echo $v['type']==3 ? '会员':'助理'?></td>
            <td><?php echo empty($v['name'])? '--':$v['name']?></td>
            <td>
                <?php echo empty($v['expiration_time']) ? '--':date('Y-m-d ',$v['expiration_time'])?>
            </td>
            <td><?php echo $v['integral']?></td>
            <td><?php echo $v['source']==1 ? 'PC':($v['source']==2 ? '微信':'后台添加')?></td>
            <td><?php echo $v['is_remind']==1 ? '是':'否'?></td>
            <td><?php echo empty($v['last_login_time']) ? '0':date('Y-m-d H:i:s',$v['last_login_time'])?></td>
            <td><?php echo empty($v['create_time']) ? '0':date('Y-m-d H:i:s',$v['create_time'])?></td>
            <td class="td-status"><span class="label <?php echo $v['status'] == 1 ? 'label-success' : 'label-defaunt';?> radius"><?php echo $v['status'] == 1 ? '已启用' : '已禁用';?></span></td>
                <td class="td-manage" >
                    <?php if($v['status'] == 1){?>
                    <a href="javascript:;" title="禁用" onclick="stop(this,'<?php echo $v['uid']?>','<?php echo $v['status']?>')" style="text-decoration:none"><i class="Hui-iconfont">&#xe631;</i></a>
                    <?php } else if($v['status'] == 2) {?>
                    <a href="javascript:;" title="启用" onclick="start(this,'<?php echo $v['uid']?>','<?php echo $v['status']?>')" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e1;</i></a>
                    <?php }?>
                <a title="编辑" href="javascript:;" onclick="admin_edit('用户编辑','<?php echo Url('User/userSave',array('uid'=>$v['uid']))?>',<?php echo $v['uid']?>)" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>
                <a title="续费" href="javascript:;" onclick="admin_edit('会员续费','<?php echo Url('Order/orderAdd',array('uid'=>$v['uid']))?>',<?php echo $v['uid']?>)" style="text-decoration:none"><i class="Hui-iconfont">&#xe6b9;</i></a>

                    <a title="重置密码"  href="javascript:;"  onclick="repassword(this,<?php echo $v['uid']?>)" style="text-decoration:none" class="ml-5"><i class="Hui-iconfont">&#xe63f;</i></a>
            </tr>
            <?php } ?>
            <tr>
                <td colspan="16" align="right">
                    <div class="pages">
                        {$result.list->render()}
                    </div>
                </td>
            </tr>
            <?php if(empty($result['list'])):?>
            <tr class="text-l"><td colspan="20">没有找到匹配的记录</td></tr>
            <?php endif;?>
            </tbody>
        </table>
    </div>
    </form>
</div>
<script type="text/javascript" src="__PUBLIC__/admin/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/lib/layer/2.1/layer.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/lib/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/static/h-ui/js/H-ui.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/static/h-ui.admin/js/H-ui.admin.js"></script>

<script type="text/javascript" src="__PUBLIC__/admin/lib/jquery.validation/1.14.0/jquery.validate.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/lib/jquery.validation/1.14.0/messages_zh.min.js"></script>

<script type="text/javascript">
    $('.table-sort').dataTable({
        "aaSorting": [[ 6, "desc" ]],//默认第几个排序
        "bStateSave": true,//状态保存
        "aoColumnDefs": [
            //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
            // {"orderable":false,"aTargets":[0,8]}// 不参与排序的列
        ]
    });
    /*添加*/
    function admin_add(title,url,w,h){
        layer_show(title,url,w,h);
    }
    /*编辑*/
    function admin_edit(title,url,id,w,h){
        layer_show(title,url,w,h);
    }
    /*删除*/
    function admin_del(obj,uid){
        layer.confirm('确认要删除吗？',function(index){
            $.ajax({
                type:'get',
                url:"<?php echo Url('User/userDelete')?>",
                data:{"uid":uid},
                success:function(data){
                    if(data.code == 0){
                        layer.msg(data.msg,{icon:1,time:1000});
                    }else{
                        layer.msg(data.msg,{icon:5,time:1000});
                    }

                }
            });
            //此处请求后台程序，下方是成功后的前台处理……
            $(obj).parents("tr").remove();
            layer.msg('已删除!',{icon:1,time:1000});
        });
    }

    /*停用*/
    function stop(obj,id,status){
        layer.confirm('确认要停用吗？',function(index){
            $.ajax({
                type:'post',
                url:"<?php echo url('User/userStatusChange')?>",
                data:{"id":id,"status":status},
                success:function(data){
                    if(data.code == 0){
                        $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="start(this,'+id+','+data.data.status+')" href="javascript:;" title="启用"><i class="Hui-iconfont">&#xe6e1;</i></a>');
                        $(obj).parents("tr").find(".td-status").html('<span class="label label-defaunt radius">已禁用</span>');
                        $(obj).remove();
                        layer.msg('已禁用！',{icon: 7,time:1000});
                    }else{
                        layer.msg(data.msg,{icon:5,time:1000});
                    }
                }
            });
        });
    }

    /*启用*/
    function start(obj,id,status){
        layer.confirm('确认要启用吗？',function(index){
            $.ajax({
                type:'post',
                url:"<?php echo url('User/userStatusChange')?>",
                data:{"id":id,"status":status},
                success:function(data){
                    if(data.code == 0){
                        $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="stop(this,'+id+','+data.data.status+')" href="javascript:;" title="禁用"><i class="Hui-iconfont">&#xe631;</i></a>');
                        $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已启用</span>');
                        $(obj).remove();
                        layer.msg('已启用！',{icon: 1,time:1000});
                    }else{
                        layer.msg(data.msg,{icon:5,time:1000});
                    }
                }
            });
        });
    }
    /*重置密码*/
    function repassword(obj,id){
        layer.confirm('你确定要重置密码吗？',function(index){
            $.ajax({
                type:'post',
                url:"<?php echo url('user/userChangePwd')?>",
                data:{"id":id},
                success:function(data){
                    if(data.code == 0){
                        layer.msg(data.msg,{icon:1,time:1000});
                    }else{
                        layer.msg(data.msg,{icon:5,time:1000});
                    }
                }
            });
        });
    }
    /*function exportExcel(where){
        layer.confirm('确认要导出吗？',function(index){
            $.ajax({
                type:'get',
                url:"<?php echo Url('User/export')?>",
                data:{'exportwhere':where},
                success:function(data){
                    if(data.code == 0){
                        layer.msg(data.msg,{icon:1,time:1000});
                    }else{
                        layer.msg(data.msg,{icon:5,time:1000});
                    }

                }
            });
        });
    }*/
</script>
</body>
</html>